// 预加载文件

import { contextBridge, ipcRenderer, IpcRendererEvent } from 'electron';
import { API_type } from '@p/page-ipc';

const obj: API_type = {
	on(channel: string, callback: (event: IpcRendererEvent, ...args: any[]) => void) {
		ipcRenderer.on(channel, callback);
	},
	send(channel: string, ...args: any[]) {
		ipcRenderer.send(channel, ...args);
	},
	invoke(channel: string, ...args: any[]) {
		return ipcRenderer.invoke(channel, ...args);
	},
};

contextBridge.exposeInMainWorld('API', obj);
